﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// [assembly: log4net.Config.XmlConfigurator(Watch = true)]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net", ConfigFileExtension = "config", Watch = true)]


namespace Simhopp.Common
{
    public static class MyLogger
    {
        private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public static void Debug(String message)
        {
            if (log.IsDebugEnabled)
            {
                var callingMethod = new StackTrace().GetFrame(1).GetMethod();
                var name = callingMethod.ReflectedType.Name;
                log.Debug(String.Format("{0} - {1}", name, message));
            }
        }

        public static void Info(String message)
        {
            if (log.IsInfoEnabled)
            {
                var callingMethod = new StackTrace().GetFrame(1).GetMethod();
                var name = callingMethod.ReflectedType.Name;
                log.Info(String.Format("{0} - {1}", name, message));
            }
        }

        public static void Warn(String message)
        {
            if (log.IsWarnEnabled)
            {
                var callingMethod = new StackTrace().GetFrame(1).GetMethod();
                var name = callingMethod.ReflectedType.Name;
                log.Warn(String.Format("{0} - {1}", name, message));
            }
        }

        public static void Error(String message)
        {
            if (log.IsErrorEnabled)
            {
                var callingMethod = new StackTrace().GetFrame(1).GetMethod();
                var name = callingMethod.ReflectedType.Name;
                log.Error(String.Format("{0} - {1}", name, message));
            }
        }

        public static void Fatal(String message)
        {
            if (log.IsFatalEnabled)
            {
                var callingMethod = new StackTrace().GetFrame(1).GetMethod();
                var name = callingMethod.ReflectedType.Name;
                log.Fatal(String.Format("{0} - {1}", name, message));
            }
        }

    }

}
